package com.jiang.controller;

import com.alibaba.fastjson.JSON;
import com.jiang.bean.MainMenu;
import com.jiang.service.MenuService;
import com.jiang.service.UserService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@RestController
public class MenuController {

    @Resource
    MenuService menuService;

    @CrossOrigin
    @RequestMapping("/menus")
    public String getAllMenus() {
        HashMap<String, Object> data = new HashMap<>();
        List<MainMenu> mainMenus = menuService.getMainMenus();
        data.put("data", mainMenus);
        data.put("status", 200);
        String data_json = JSON.toJSONString(data);
        System.out.println("成功访问！！！");
        return data_json;
    }
}
